package com.hfy.kandian.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hfy.kandian.service.BookService;
import com.hfy.kandian.service.SearchService;
import com.hfy.kandian.service.WriterService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/search")
public class SearchController {
    @Autowired
    private BookService bookService;

    @Autowired
    private WriterService writerService;

    @Autowired
    private SearchService searchService;


    @ApiOperation(value = "全站搜索作者或书籍")
    @GetMapping("/all/{keyword}")
    public Map<String, List> searchAll(@PathVariable String keyword) {

        return searchService.searchAll(keyword);
    }

    @ApiOperation(value = "书架内搜索作者或书籍")
    @GetMapping("/bookshelf/{userId}/{keyword}")
    public Map<String,List> searchBookshlef(@PathVariable int userId,@PathVariable String keyword){
        return searchService.searchBookshlef(userId,keyword);
    }

}
